package com.ustc.hewei.consumerweb.controller;


import com.ustc.hewei.commonmodule.dto.Result;
import com.ustc.hewei.commonmodule.service.IVoucherOrderService;
import com.ustc.hewei.consumerweb.utils.UserHolder;
import com.ustc.hewei.nettyrpc2_0.common.annotation.AutowireService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hewei
 * @since 2022-10-05
 */
@RestController
@RequestMapping("/voucher-order")
public class VoucherOrderController {
    public IVoucherOrderService getVoucherOrderService() {
        return voucherOrderService;
    }

    public void setVoucherOrderService(IVoucherOrderService voucherOrderService) {
        this.voucherOrderService = voucherOrderService;
    }

    @Resource
    private IVoucherOrderService voucherOrderService;

    @PostMapping("/seckill/{id}")
    public Result seckillVoucher(@PathVariable("id") Long voucherId) {
        return voucherOrderService.secKillVoucher(UserHolder.getUser(), voucherId);
    }
}

